package com.example.provider.serviceImpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.example.provider.dao.UserDao;
import com.example.provider.entity.User;
import com.example.provider.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;


import java.util.List;
import java.util.Optional;

@Service(version = "1.0.0",timeout = 3000)
public class UserServiceImpl implements UserService {
    @Autowired
    UserDao userDao;
    private List<User> users;

    @Override
    public void insertUser(User user){
        userDao.save(user);
    }

    @Override
    public void deleteUser(Integer id){
        userDao.deleteById(id);
    }

    @Override
    public void updateUser(User user){
        userDao.save(user);
    }

    @Override
    public List<User> getUser(){
        return (List<User>) userDao.findAll();
    }

    @Override
    public Optional<User> getUserById(Integer id){
        return userDao.findById(id);
    }
}
